

use "~/Dropbox/Independent candidates Chile/01_data/clean_data/wave1.dta", clear
set scheme plottig 

cd "~/Dropbox/Independent candidates Chile/02_analyses/figures"


// Manuscript

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4, cl(key)
coefplot,   omitted baselevels horizontal keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(medium)) ciopts(lwidth(medthick) recast(rcap))
graph export all.tif, replace width(2550)


reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 0, cl(key)
estimates store np

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 1, cl(key) 
estimates store pop


coefplot (np, offset(0) label("Non-Anti-Elite")) (pop, offset(-0.05)  label("Anti-Elite")),   omitted baselevels ///
horizontal keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace) legend(col(1) ring(0) pos(2))  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Comparison", size(medium)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int.tif, replace width(2550)

* Forced

reg choice_forced  i.indep i.atr2 i.atr3 i.atr4, cl(key)
coefplot,   omitted baselevels horizontal keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(medium)) ciopts(lwidth(medthick) recast(rcap))
graph export all_forced.png, replace


reg choice_forced  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 0, cl(key)
estimates store np_forced

reg choice_forced  i.indep i.atr2 i.atr3 i.atr4 if populism2 == 1, cl(key) 
estimates store pop_forced

coefplot (np_forced, offset(0) label("Non-Anti-Elite")) (pop_forced, offset(-0.05)  label("Anti-Elite")),   omitted baselevels ///
horizontal keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace) legend(col(1) ring(0) pos(2))  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Comparison", size(medium)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int_forced.png, replace


* Appendix A

// Basic regression

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 , cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep 0.atr2 1.atr2  2.atr2  3.atr2 0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 0.atr4 1.atr4 2.atr4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) ///
xlabel(-0.25(0.1)0.25, labcolor(black))  ///
headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" 1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) ///
coeflabels(0.indep = "Party" 1.indep = "Independent" 1.atr2 = "Lawyer" 2.atr2 = "School Teacher" 3.atr2 = "Street Vendor"  /// 
1.atr3 = "35" 2.atr3 = "45" 3.atr3 = "55" 4.atr3 = "65" 1.atr4 = "Male" 2.atr4 = "Female" ,labcolor(black))
graph export coef_plot_basic.png, replace

reg choice_clean i.indep  populism2  indep_populism2  i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2, cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep indep_populism2  0.atr2 1.atr2  2.atr2  3.atr2  2.atr2#1.populism2 3.atr2#1.populism2 ///
0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 2.atr3#1.populism2 3.atr3#1.populism2 4.atr3#1.populism2 0.atr4 1.atr4 2.atr4  2.atr4#1.populism2) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) ///
xlabel(-0.25(0.1)0.25, labcolor(black))  headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" ///
1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) ///
coeflabels(0.indep = "Party" 1.indep = "Independent" indep_populism2 = "Independent*Anti-Elite" 1.atr2 = "Lawyer" 2.atr2 = "School Teacher" 3.atr2 = "Street Vendor"  /// 
1.atr3 = "35" 2.atr3 = "45" 3.atr3 = "55" 4.atr3 = "65" 1.atr4 = "Male" 2.atr4 = "Female" 2.atr2#1.populism2 = "School Teacher*Anti-Elite" 3.atr2#1.populism2 = "Street Vendor*Anti-Elite" ///
2.atr3#1.populism2 = "45*Anti-Elite" 3.atr3#1.populism2 = "55*Anti-Elite" 4.atr3#1.populism2 = "65*Anti-Elite" 2.atr4#1.populism2 = "Female*Anti-Elite",labcolor(black))
graph export coef_plot_basic_int.png, replace

// Tables

cd "~/Dropbox/Independent candidates Chile/02_analyses/tables"

reg choice_clean indep atr2_cat2 atr2_cat3 atr3_cat2 atr3_cat3 atr3_cat4 atr4_cat2 , cl(key)
outreg2 using basic, replace tex(fragment)  dec(3)  keep(indep atr2_cat2 atr2_cat3 atr3_cat2 atr3_cat3 atr3_cat4 atr4_cat2)  label   ///
nocons addstat(R^2, e(r2), Obs., e(N)) nor2 noobs  nonotes ctitle("Non-Interacted")

reg choice_clean indep atr2_cat2 atr2_cat3 atr3_cat2 atr3_cat3 atr3_cat4 atr4_cat2 indep_populism2 populism2_atr2_cat3 populism2_atr3_cat2 ///
populism2_atr3_cat3 populism2_atr3_cat4 populism2_atr4_cat2, cl(key)
outreg2 using basic, append tex(fragment)  dec(3)  keep(indep atr2_cat2 atr2_cat3 atr3_cat2 atr3_cat3 atr3_cat4 atr4_cat2 ///
indep_populism2 populism2_atr2_cat2 populism2_atr2_cat3 populism2_atr3_cat2 populism2_atr3_cat3 populism2_atr3_cat4 populism2_atr4_cat2)  label   ///
nocons addstat(R^2, e(r2), Obs., e(N)) nor2 noobs nonotes ctitle("Interacted")


* Appendix B

// Alternative Measure

cd "~/Dropbox/Independent candidates Chile/02_analyses/figures"

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export all_alt.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism1 == 0, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(npop, replace)  ///
coeflabels(0.indep = "       " 1.indep = "               ", labsize(medium) labcolor(black)) title("Non-Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop1_alt.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism1 == 1, cl(key) 
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop2_alt.png, replace

reg choice_clean i.indep  populism1  indep_populism1  i.atr2##i.populism1 i.atr3##i.populism1 i.atr4##i.populism1, cl(key)
coefplot,   omitted baselevels keep(0.indep indep_populism1)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(inte, replace)   ///
coeflabels(0.indep = "       " indep_populism1 = "                ", labsize(medium) labcolor(black)) title("Difference", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int_alt.png, replace

// Strict measure

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export all_alt2.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism_both == 0, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(npop, replace)  ///
coeflabels(0.indep = "       " 1.indep = "               ", labsize(medium) labcolor(black)) title("Non-Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop1_alt2.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 if populism_both == 1, cl(key) 
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop2_alt2.png, replace

reg choice_clean i.indep  populism1  indep_populism_both  i.atr2##i.populism_both i.atr3##i.populism_both i.atr4##i.populism_both, cl(key)
coefplot,   omitted baselevels keep(0.indep indep_populism_both)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(inte, replace)   ///
coeflabels(0.indep = "       " indep_populism_both = "                ", labsize(medium) labcolor(black)) title("Difference", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int_alt2.png, replace


// Controls

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 i.region i.nse i.education i.device i.sex age  duration_min, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export all_con.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 i.region i.nse i.education i.device i.sex age  duration_min if populism2 == 0, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(npop, replace)  ///
coeflabels(0.indep = "       " 1.indep = "               ", labsize(medium) labcolor(black)) title("Non-Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop1_con.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 i.region i.nse i.education i.device i.sex age  duration_min if populism2 == 1, cl(key) 
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop2_con.png, replace

reg choice_clean i.indep  populism2  indep_populism2 i.region i.nse i.education i.device i.sex age  duration_min i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2, cl(key)
coefplot,   omitted baselevels keep(0.indep indep_populism2)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(inte, replace)   ///
coeflabels(0.indep = "       " indep_populism2 = "                ", labsize(medium) labcolor(black)) title("Difference", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int_con.png, replace



// IPW

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 [aw = ipw], cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export all_ipw.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 [aw = ipw] if populism2 == 0, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(npop, replace)  ///
coeflabels(0.indep = "       " 1.indep = "               ", labsize(medium) labcolor(black)) title("Non-Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop1_ipw.png, replace

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 [aw = ipw] if populism2 == 1, cl(key) 
coefplot,   omitted baselevels keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Anti-Elite", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop2_iwp.png, replace

reg choice_clean i.indep  populism2  indep_populism2  duration_min i.atr2##i.populism2 i.atr3##i.populism2 i.atr4##i.populism2 [aw = ipw], cl(key)
coefplot,   omitted baselevels keep(0.indep indep_populism2)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(inte, replace)   ///
coeflabels(0.indep = "       " indep_populism2 = "                ", labsize(medium) labcolor(black)) title("Difference", size(large)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_int_ipw.png, replace


* Balance IPW


balancetable populism2 nse education female region_13 age duration_min dev_3 ///
left right centrist non_ideological vote_2017_1 using "balance_pop.tex" , ctitles("Non-Anti-Elite" "Anti-Elite" "Difference") varlabels  replace 

balancetable populism2 nse education female region_13 age duration_min dev_3 ///
left right centrist non_ideological vote_2017_1 [aw = ipw] using "balance_pop_ipw.tex" , ctitles("Non-Anti-Elite" "Anti-Elite" "Difference") varlabels  replace 

* Appendix E

// 4 separate regressions

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 if celda == 1, cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep 0.atr2 1.atr2  2.atr2  3.atr2 0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 0.atr4 1.atr4 2.atr4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) title("Control") ///
xlabel(-0.25(0.1)0.25, labsize(small) labcolor(black))  name(control, replace) ///
headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" 1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) coeflabels(,labcolor(black))

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 if celda == 2, cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep 0.atr2 1.atr2  2.atr2  3.atr2 0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 0.atr4 1.atr4 2.atr4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) title("Representation") ///
xlabel(-0.25(0.1)0.25, labsize(small) labcolor(black))  name(rep, replace) ///
headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" 1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) coeflabels(,labcolor(black))

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 if celda == 3, cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep 0.atr2 1.atr2  2.atr2  3.atr2 0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 0.atr4 1.atr4 2.atr4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) title("Malfeasance") ///
xlabel(-0.25(0.1)0.25, labsize(small) labcolor(black))  name(mal, replace) ///
headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" 1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) coeflabels(,labcolor(black))

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 if celda == 4, cl(key)
coefplot, omitted baselevels horizontal  keep(0.indep 1.indep 0.atr2 1.atr2  2.atr2  3.atr2 0.atr3 1.atr3 2.atr3 3.atr3 4.atr3 0.atr4 1.atr4 2.atr4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.25(0.1)0.25)) title("Inequality") ///
xlabel(-0.25(0.1)0.25, labsize(small) labcolor(black)) name(ine, replace) ///
headings(0.indep="{bf:Party Affiliation}" 1.atr2="{bf:Occupation}" 1.atr3="{bf:Age}" 1.atr4="{bf:Gender}", labcolor(black)) ciopts(recast(rcap)) coeflabels(,labcolor(black))


graph combine control rep mal ine
graph export coef_plot_prime.png, replace

// Interactions prime

reg choice_clean i.indep i.atr2 i.atr3 i.atr4 celda_cat2 celda_cat3 celda_cat4 ind_celda_cat2 ind_celda_cat3 ind_celda_cat4 ///
i.celda##i.atr2 i.celda##i.atr3  i.celda##i.atr4, cl(key)

coefplot, omitted baselevels horizontal  keep(0.indep 1.indep ind_celda_cat2 ind_celda_cat3 ind_celda_cat4) ///
xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.15)) ///
xlabel(0 0.05 0.1 0.15,  labcolor(black)) ciopts(recast(rcap)) coeflabels(,labcolor(black))
graph export coef_plot_prime_int.png, replace


// Diagnostics


// Balance regressions

cd "~/Dropbox/Independent candidates Chile/02_analyses/tables"

reg duration_min  indep i.atr2 i.atr3 i.atr4 celda_cat2 celda_cat3 celda, cl(key)
outreg2 using balance, replace tex  dec(3)  keep(indep i.atr2 i.atr3 i.atr4)  label   ///
nocons addstat(R^2, e(r2), Obs., e(N)) nor2 noobs  

reg female  indep i.atr2 i.atr3 i.atr4 celda_cat2 celda_cat3 celda, cl(key)
outreg2 using balance, append tex  dec(3)  keep(indep i.atr2 i.atr3 i.atr4 )  label   ///
nocons addstat(R^2, e(r2), Obs., e(N)) nor2 noobs  

reg age  indep i.atr2 i.atr3 i.atr4 celda_cat2 celda_cat3 celda, cl(key)
outreg2 using balance, append tex  dec(3)  keep(indep i.atr2 i.atr3 i.atr4 )  label   ///
nocons addstat(R^2, e(r2), Obs., e(N)) nor2 noobs  

reg nse  indep i.atr2 i.atr3 i.atr4 celda_cat2 celda_cat3 celda, cl(key)
outreg2 using balance, append tex  dec(3)  keep(indep i.atr2 i.atr3 i.atr4 )  label   ///
nocons addstat(R^2, e(r2), Obs., e(N)) nor2 noobs  

reg education  indep i.atr2 i.atr3 i.atr4 celda_cat2 celda_cat3 celda, cl(key)
outreg2 using balance, append tex  dec(3)  keep(indep i.atr2 i.atr3 i.atr4 )  label   ///
nocons addstat(R^2, e(r2), Obs., e(N)) nor2 noobs  


// Order effect (left vs right)

reg choice_clean  i.indep##i.posicion i.atr2 i.atr3 i.atr4, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep 1.indep#2.posicion)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent" 1.indep#2.posicion = "Right Side*Independent" , labsize(medium) labcolor(black))  ciopts(lwidth(medthick) recast(rcap))
graph export all_order.png, replace

// Wave effect

reg choice_clean  i.indep##ib5.set i.atr2 i.atr3 i.atr4, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep 1.indep#1.set 1.indep#2.set 1.indep#3.set 1.indep#4.set)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent" 1.indep#1.set = "Wave 1*Independent" 1.indep#2.set = "Wave 2*Independent" ///
1.indep#3.set = "Wave 3*Independent" 1.indep#4.set = "Wave 4*Independent", labsize(medium) labcolor(black))  ciopts(lwidth(medthick) recast(rcap))
graph export all_wave.png, replace

// Addressing comments: independent versus other combinations


reg choice_clean  party_3 party_2 party_1 party_5 party_4 i.atr2 i.atr3 i.atr4, cl(key)

coefplot,   omitted baselevels horizontal keep(party_4  party_3 party_2 party_1 party_5 )  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.21(0.1)0.05)) /// 
xlabel(-0.2 -0.15 -0.1 -0.05 0 0.05, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) ///
coeflabels( party_4 = "Independent" party_1 = "Center-Right" party_2 = "Center-Left" party_3 = "Left"  party_5 ="Right", ///
labsize(medium) labcolor(black))  ciopts(lwidth(medthick) recast(rcap)) ///
order(party_4 party_3 party_2 party_1 party_5 )
graph export ind_party_all.png, replace



reg choice_clean    party_3 party_2 party_1 party_5 party_4 i.atr2 i.atr3 i.atr4 if populism2 == 0, cl(key)
estimates store np_party

reg choice_clean    party_3 party_2 party_1 party_5 party_4  i.atr2 i.atr3 i.atr4 if populism2 == 1, cl(key) 
estimates store pop_party


coefplot (np_party, offset(0.05) label("Non-Anti-Elite")) (pop_party, offset(-0.05) label("Anti-Elite")), omitted baselevels ///
horizontal keep(party_1 party_2 party_3 party_5 party_4)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.21(0.1)0.05)) ///
xlabel(-0.2 -0.15 -0.1 -0.05 0 0.05, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace) legend(col(1) ring(0) pos(-2))  ///
coeflabels(party_1 = "Center-Right" party_2 = "Center-Left" party_3 = "Left" party_4 = "Independent" party_5 ="Right", ///
labsize(medium) labcolor(black))  title("Comparison", size(medium)) ciopts(lwidth(medthick) recast(rcap)) ///
order(party_4 party_3 party_2 party_1 party_5 )
graph export pop_int_party.png, replace

// Days to election

reg choice_clean  i.indep days_election days_election_ind i.atr2 i.atr3 i.atr4, cl(key)
coefplot,   omitted baselevels keep(0.indep 1.indep days_election_ind)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(all, replace)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent" days_election_ind = "Days*Independent" , labsize(medium) labcolor(black))  ciopts(lwidth(med) recast(rcap))
graph export all_days_election.png, replace



// Days election descriptive


binscatter populism1 populism2  populism_both days_election, linetype(connect) ytitle("Anti-Elite Atttitudes") xtitle("Days to the Election") color(black) ///
msymbol(triangle circle diamond)  xlabel(, labsize(small) labcolor(black)) ylabel(, labsize(small) labcolor(black)) xsc(reverse)  legend(lab(1 "Anti-Elite 1") lab(2 "Anti-Elite 2") ///
lab(3 "Both"))

* Regression contrling for days until the election

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 days_election, cl(key)
coefplot,   omitted baselevels horizontal keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) /// 
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6)  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Whole Sample", size(medium)) ciopts(lwidth(medthick) recast(rcap))
graph export all_days.png, replace


reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 days_election if populism2 == 0, cl(key)
estimates store np

reg choice_clean  i.indep i.atr2 i.atr3 i.atr4 days_election if populism2 == 1, cl(key) 
estimates store pop


coefplot (np, offset(0) label("Non-Anti-Elite")) (pop, offset(-0.05)  label("Anti-Elite")),   omitted baselevels ///
horizontal keep(0.indep 1.indep)  xline(0, lwidth(medium) lcolor(black)) xscale(range(-0.02(0.1)0.2)) ///
xlabel(0 0.05 0.1 0.15 0.2, labsize(medsmall) labcolor(black)) xsize(5) ysize(6) name(pop, replace) legend(col(1) ring(0) pos(2))  ///
coeflabels(0.indep = "Party" 1.indep = "Independent", labsize(medium) labcolor(black)) title("Comparison", size(medium)) ciopts(lwidth(medthick) recast(rcap))
graph export pop_days_election.png, replace



